package com.zhentao.controller;

import com.zhentao.model.dtos.ResponseResult;
import com.zhentao.model.wemedia.dto.WmNewsDto;
import com.zhentao.model.wemedia.dto.WmNewsPageReqDto;
import com.zhentao.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.security.PublicKey;

@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {

    @Autowired
    private WmNewsService wmNewsService;

    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmNewsPageReqDto pageReqDto) {
        return wmNewsService.Newslist(pageReqDto);
    }

    @PostMapping("/down_or_up")
    public ResponseResult list() {
        return null;
    }


    /**
     * 提交信息
     */
    @PostMapping("/submit")
    public ResponseResult submit(@RequestBody WmNewsDto wmNewsDto) {
        return wmNewsService.submitNews(wmNewsDto);
    }

    /**
     * 删除
     */


    @GetMapping("/del_news/{id}")
    public ResponseResult delNews(@PathVariable("id") Integer id) {
        return wmNewsService.delNews(id);
    }

    /**
     * 修改*/
    @GetMapping("/one/{id}")
    public ResponseResult one(@PathVariable("id") Integer id){
        return wmNewsService.updateOne(id);
    }
}
